import axios from 'axios'

axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

axios.interceptors.request.use(config => {
    config.headers.Authorization = sessionStorage.getItem('token')
    return config
})
axios.interceptors.response.use(res => res)

// 封装get和post方法
const get = (path: string, queryJson?: object) => {
    return axios.get(path, { params: queryJson })
}
const post = (path: string, queryJson?: object) => {
    return axios.post(path, queryJson)
}

export { get, post }